]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
ci: Make --destdir option in install-meson-project cumulative
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 4 Oct 2024 16:19:58 +0000 (18:19 +0200)
committerMarge Bot <marge-bot@gnome.org>
Thu, 5 Dec 2024 12:57:29 +0000 (12:57 +0000)
When building a system extension for GNOME OS, any extra
dependencies are needed both in the container (for building)
and the extension's destdir (for running).

Because of that, the --destdir flag that was added in commit
8aeb6dc86 does not only install to the specified directory
as expected, but also runs a second install step without
destdir (i.e. to the system).

However that behavior is not a good fit when we extend our
existing toolbox tooling to build system extensions for
Fedora instead of GNOME OS.

To account for that, make the --destdir option cumulative
and install the project to all provided destdirs (or /
if omitted).

This gives us the flexibility to install to the system, a
different destdir, or both:

```
 $ ./install-meson-project.sh  # install to system
 $ ./install-meson-project.sh --destdir /new/dest  # install to destdir
 $ ./install-meson-project.sh --destdir /new/dest --destdir /  # both
```

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3498>

.gitlab-ci/install-meson-project.sh

index bcc67cf9efa19557190e5eed591f71cc98aed5c4..8afd4079ec2e044e0b4809abb5832c56db71182f 100755 (executable)
@@ -13,7 +13,8 @@ usage() {
          --subdir=DIR       Build subdirectory instead of whole project
          --prepare=SCRIPT   Script to run before build
          --libdir=DIR       Setup the project with a different libdir
-         --destdir=DIR      Install the project to an additional destdir
+         --destdir=DIR      Install the project to DIR, can be used
+                            several times to install to multiple destdirs
 
          -h, --help         Display this help
 
@@ -36,7 +37,7 @@ unset TEMP
 MESON_OPTIONS=()
 SUBDIR=.
 PREPARE=:
-DESTDIR=""
+DESTDIRS=()
 
 while true; do
   case "$1" in
@@ -61,7 +62,7 @@ while true; do
     ;;
 
     --destdir)
-      DESTDIR=$2
+      DESTDIRS+=( $2 )
       shift 2
     ;;
 
@@ -85,6 +86,8 @@ fi
 REPO_URL="$1"
 COMMIT="$2"
 
+[[ ${#DESTDIRS[@]} == 0 ]] && DESTDIRS+=( / )
+
 CHECKOUT_DIR=$(mktemp --directory)
 trap "rm -rf $CHECKOUT_DIR" EXIT
 
@@ -94,10 +97,11 @@ pushd "$CHECKOUT_DIR/$SUBDIR"
 sh -c "$PREPARE"
 meson setup --prefix=/usr _build "${MESON_OPTIONS[@]}"
 
-# Install it to an additional directory e.g., system extension directory
-if [ -n "${DESTDIR}" ]; then
-    sudo meson install -C _build --destdir=$DESTDIR
-fi
-
-sudo meson install -C _build
+# Install it to all specified dest dirs
+for destdir in "${DESTDIRS[@]}"; do
+    # don't use --destdir when installing to root,
+    # so post-install hooks are run
+    [[ $destdir == / ]] && destdir=
+    sudo meson install -C _build ${destdir:+--destdir=$destdir}
+done
 popd